package 算法.LeetCode91.每日打卡题目;

import 算法.NiuKe.TreeNode;

import java.util.LinkedList;
import java.util.Queue;

/**
 * @author: 谢君臣
 * @create: 2021-02-16 9:57
 * @founction: XXXX
 */
public class day16 {
    public static void main(String[] args) {

    }
    public int findBottomLeftValue(TreeNode root) {
        return BFS(root);
    }
    private int BFS(TreeNode root) {
        Queue<TreeNode> queue = new LinkedList<>();
        queue.add(root);
        int temp = 0;
        while (!queue.isEmpty()){
            TreeNode node = queue.poll();
            temp = node.val;
            if (node.right!=null) queue.add(node.right);
            if (node.left!=null) queue.add(node.left);
        }
        return temp;
    }
}
